<?php if (!defined('SERVER_ROOT')) { exit('No direct script access allowed');}
$this->template->title = 'Phân quyền cho cán bộ';
$v_pop_win = isset($_REQUEST['pop_win']) ? '_pop_win' : '';
$this->template->display('dsp_header' . $v_pop_win . '.php');
?>
<form name="frmMain" method="post" id="frmMain" action=""><?php
    echo $this->hidden('controller', $this->get_controller_url());
    echo $this->hidden('hdn_dsp_single_method', 'dsp_single_loaidonvi');
    echo $this->hidden('hdn_dsp_all_method', 'dsp_all_loaidonvi');
    echo $this->hidden('hdn_update_method', 'update_loaidonvi');
    echo $this->hidden('hdn_delete_method', 'delete_loaidonvi');
    echo $this->hidden('pop_win', $v_pop_win);
    echo $this->hidden('hdn_item_id', $var_macanbo);
    echo $this->hidden('hdn_phan_nhomquyen', '');
    ?>
    <h5 style="text-align: center"><?php echo $var_tencanbo; ?></h5>
    <div class="Row" id="div_phan_nhomquyen">
          <table style="background-color: #FFFFFF" width="100%" class="adminlist" cellspacing="0" border="1" id="tbl_user_in_group">
                <colgroup>
                    <col width="10%" />
                    <col width="90%" />

                </colgroup>
                <tr>
                    <th>All</th>
                    <th>Nhóm quyền</th>
                </tr>
                <?php while ($arr = $arr_all_nhomquyen->FetchRow()): ?>
                <?php
                $MA = $arr['MA_NHOM_QUYEN'];
                $TEN = $arr['TEN_NHOM_QUYEN'];
                $CHECKED = $arr['CHECKED'];
                ?>
                    <tr id="tr_<?php echo $MA; ?>">
                        <td class="center">
                            <input type="checkbox"
                                   name="chk_group"
                                   value="<?php echo $MA; ?>"
                                   id="<?php echo $MA; ?>"
                                   <?php if ($CHECKED == 1): ?>
                                       checked
                                   <?php endif; ?>
                                   />
                        </td>
                        <td>
                            <label for="<?php echo $MA; ?>"><?php echo $TEN; ?></label>
                        </td>
                    </tr>
            <?php endwhile; ?>
            </table>
    </div>
    <div class="button-area">
        <input type="button" name="update" class = 'button save' value="Cập nhật" onclick="btn_update_lvxl_onclick();"/>
        <?php $v_back_action = ($v_pop_win === '') ? 'btn_back_onclick();' : 'try{window.parent.hidePopWin();}catch(e){window.close();};';?>
        <input type="button" name="cancel" class = 'button close' value="Bỏ qua" onclick="<?php echo $v_back_action;?>"/>
    </div>

</form>
<script type="text/javascript">
function btn_update_lvxl_onclick()
    {
        var q = "#div_phan_nhomquyen input[type='checkbox']";
        var arr_checked_nhomquyen = new Array();
        $(q).each(function(index) {
            if ($(this).is(':checked'))
            {
                arr_checked_nhomquyen.push($(this).attr('id'));
            }
        });

        $('#hdn_phan_nhomquyen').val(arr_checked_nhomquyen.join());

        var f = document.frmMain;
        m = $("#controller").val() + 'update_nhomquyencanbo/0/';
        //alert(m) ;
        var xObj = new DynamicFormHelper('','',f);
        if (xObj.ValidateForm(f)){
            $("#frmMain").attr("action", m);
            f.submit();
        }
}
</script>
<?php $this->template->display('dsp_footer' .$v_pop_win . '.php');